package com.straw.hat.shardingjdbc;

import com.straw.hat.shardingjdbc.dao.UserMapper;
import com.straw.hat.shardingjdbc.entity.UserInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @company: 鲸灵科技
 * @author: qiyue@webuy.ai
 * @date: 2019/10/7
 * @time: 2:18 下午
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {ShardingJdbcApplication.class})
public class ShardingJdbcTstApplication {

    @Autowired
    private UserMapper userMapper;

    @Test
    public void testSelect(){
        UserInfo userInfo = userMapper.findWithId(1L);
        System.out.println(userInfo.toString());
    }

    @Test
    @Rollback(false)
    public void testInsert(){
        UserInfo userInfo = new UserInfo();
        userInfo.setName("杨彬彬");
        userInfo.setAge(2);
        userInfo.setCity(2);
        userInfo.setId(1L);
        userMapper.insert(userInfo);
    }
}
